{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from rqdatac import *\n",
    "import rqdatac as rq\n",
    "\n",
    "\n",
    "rq.init('15268829004', '123456')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2010-04-19    IF1005\n",
       "2010-04-20    IF1005\n",
       "2010-04-21    IF1005\n",
       "2010-04-22    IF1005\n",
       "2010-04-23    IF1005\n",
       "               ...  \n",
       "2021-12-20    IF2201\n",
       "2021-12-21    IF2201\n",
       "2021-12-22    IF2201\n",
       "2021-12-23    IF2201\n",
       "2021-12-24    IF2201\n",
       "Name: dominant, Length: 2843, dtype: object"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# futures.get_dominant('IF', '20160801')\n",
    "futures.get_dominant('IF', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2018-12-11    EG1906\n",
       "2018-12-12    EG1906\n",
       "2018-12-13    EG1906\n",
       "2018-12-14    EG1906\n",
       "2018-12-17    EG1906\n",
       "               ...  \n",
       "2021-12-20    EG2205\n",
       "2021-12-21    EG2205\n",
       "2021-12-22    EG2205\n",
       "2021-12-23    EG2205\n",
       "2021-12-24    EG2205\n",
       "Name: dominant, Length: 739, dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "futures.get_dominant('eg', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2012-12-31    RM1305\n",
       "2013-01-04    RM1305\n",
       "2013-01-07    RM1305\n",
       "2013-01-08    RM1305\n",
       "2013-01-09    RM1305\n",
       "               ...  \n",
       "2021-12-20    RM2205\n",
       "2021-12-21    RM2205\n",
       "2021-12-22    RM2205\n",
       "2021-12-23    RM2205\n",
       "2021-12-24    RM2205\n",
       "Name: dominant, Length: 2184, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "futures.get_dominant('RM', end_date='20220501')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_book_id</th>\n",
       "      <th>symbol</th>\n",
       "      <th>abbrev_symbol</th>\n",
       "      <th>type</th>\n",
       "      <th>listed_date</th>\n",
       "      <th>de_listed_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>C2005C2180</td>\n",
       "      <td>玉米2005购2180</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-05-21</td>\n",
       "      <td>2020-04-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CU2002C49000</td>\n",
       "      <td>铜2002购49000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-02-18</td>\n",
       "      <td>2020-01-20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>CU2001C51000</td>\n",
       "      <td>铜2001购51000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-01-16</td>\n",
       "      <td>2019-12-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>M2007P2650</td>\n",
       "      <td>豆粕2007沽2650</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-07-16</td>\n",
       "      <td>2020-06-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CF1909P13000</td>\n",
       "      <td>棉花1909沽13000</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2019-05-15</td>\n",
       "      <td>2019-08-05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62668</th>\n",
       "      <td>688220.XSHG</td>\n",
       "      <td>翱捷科技</td>\n",
       "      <td>AJKJ</td>\n",
       "      <td>CS</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62669</th>\n",
       "      <td>159831.XSHE</td>\n",
       "      <td>嘉实上海金ETF</td>\n",
       "      <td>JSSHJETF</td>\n",
       "      <td>ETF</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62670</th>\n",
       "      <td>10003877</td>\n",
       "      <td>50ETF购2月3700</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>2022-02-23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62671</th>\n",
       "      <td>10003878</td>\n",
       "      <td>50ETF沽2月3700</td>\n",
       "      <td>None</td>\n",
       "      <td>Option</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>2022-02-23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62672</th>\n",
       "      <td>517760.XSHG</td>\n",
       "      <td>浦银消费龙头ETF</td>\n",
       "      <td>PYXFLTETF</td>\n",
       "      <td>ETF</td>\n",
       "      <td>2999-12-31</td>\n",
       "      <td>0000-00-00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>62673 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      order_book_id        symbol abbrev_symbol    type listed_date  \\\n",
       "0        C2005C2180   玉米2005购2180          None  Option  2019-05-21   \n",
       "1      CU2002C49000   铜2002购49000          None  Option  2019-02-18   \n",
       "2      CU2001C51000   铜2001购51000          None  Option  2019-01-16   \n",
       "3        M2007P2650   豆粕2007沽2650          None  Option  2019-07-16   \n",
       "4      CF1909P13000  棉花1909沽13000          None  Option  2019-05-15   \n",
       "...             ...           ...           ...     ...         ...   \n",
       "62668   688220.XSHG          翱捷科技          AJKJ      CS  2999-12-31   \n",
       "62669   159831.XSHE      嘉实上海金ETF      JSSHJETF     ETF  2999-12-31   \n",
       "62670      10003877  50ETF购2月3700          None  Option  2021-12-24   \n",
       "62671      10003878  50ETF沽2月3700          None  Option  2021-12-24   \n",
       "62672   517760.XSHG     浦银消费龙头ETF     PYXFLTETF     ETF  2999-12-31   \n",
       "\n",
       "      de_listed_date  \n",
       "0         2020-04-08  \n",
       "1         2020-01-20  \n",
       "2         2019-12-25  \n",
       "3         2020-06-05  \n",
       "4         2019-08-05  \n",
       "...              ...  \n",
       "62668     0000-00-00  \n",
       "62669     0000-00-00  \n",
       "62670     2022-02-23  \n",
       "62671     2022-02-23  \n",
       "62672     0000-00-00  \n",
       "\n",
       "[62673 rows x 6 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_instruments(type=None, market='cn', date=None)\n",
    "\n",
    "# type : CS\tCommon Stock, 即股票   Future\tFutures，即期货，包含股指、国债和商品期货"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_book_id</th>\n",
       "      <th>underlying_symbol</th>\n",
       "      <th>market_tplus</th>\n",
       "      <th>symbol</th>\n",
       "      <th>margin_rate</th>\n",
       "      <th>maturity_date</th>\n",
       "      <th>type</th>\n",
       "      <th>trading_code</th>\n",
       "      <th>exchange</th>\n",
       "      <th>product</th>\n",
       "      <th>contract_multiplier</th>\n",
       "      <th>round_lot</th>\n",
       "      <th>trading_hours</th>\n",
       "      <th>listed_date</th>\n",
       "      <th>industry_name</th>\n",
       "      <th>de_listed_date</th>\n",
       "      <th>underlying_order_book_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>IF88</td>\n",
       "      <td>IF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>IF主力连续</td>\n",
       "      <td>0.120</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>Future</td>\n",
       "      <td>IF2203</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>股指</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>000300.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>IF99</td>\n",
       "      <td>IF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>IF指数连续</td>\n",
       "      <td>0.120</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>Future</td>\n",
       "      <td>IF2203</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>股指</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>000300.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>TF88</td>\n",
       "      <td>TF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>年期国债主力连续</td>\n",
       "      <td>0.012</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>Future</td>\n",
       "      <td>TF2203</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Government</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:15</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>国债</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>TF99</td>\n",
       "      <td>TF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>年期国债指数连续</td>\n",
       "      <td>0.012</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>Future</td>\n",
       "      <td>TF2203</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Government</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:15</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>国债</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>T88</td>\n",
       "      <td>T</td>\n",
       "      <td>0.0</td>\n",
       "      <td>年期国债主力连续</td>\n",
       "      <td>0.020</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>Future</td>\n",
       "      <td>T2203</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Government</td>\n",
       "      <td>10000.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:15</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>国债</td>\n",
       "      <td>0000-00-00</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>962</th>\n",
       "      <td>IH2202</td>\n",
       "      <td>IH</td>\n",
       "      <td>0.0</td>\n",
       "      <td>上证50指数2202</td>\n",
       "      <td>0.120</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>Future</td>\n",
       "      <td>IH2202</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>2021-12-20</td>\n",
       "      <td>股指</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>000016.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>963</th>\n",
       "      <td>IF2202</td>\n",
       "      <td>IF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>IF2202</td>\n",
       "      <td>0.120</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>Future</td>\n",
       "      <td>IF2202</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>2021-12-20</td>\n",
       "      <td>股指</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>000300.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>964</th>\n",
       "      <td>FU2301</td>\n",
       "      <td>FU</td>\n",
       "      <td>0.0</td>\n",
       "      <td>燃料油2301</td>\n",
       "      <td>0.100</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>fu2301</td>\n",
       "      <td>SHFE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>965</th>\n",
       "      <td>SC2301</td>\n",
       "      <td>SC</td>\n",
       "      <td>0.0</td>\n",
       "      <td>原油2301</td>\n",
       "      <td>0.100</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>sc2301</td>\n",
       "      <td>INE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-02:30,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>966</th>\n",
       "      <td>LU2301</td>\n",
       "      <td>LU</td>\n",
       "      <td>0.0</td>\n",
       "      <td>低硫燃料油2301</td>\n",
       "      <td>0.100</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>lu2301</td>\n",
       "      <td>INE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>967 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    order_book_id underlying_symbol  market_tplus      symbol  margin_rate  \\\n",
       "0            IF88                IF           0.0      IF主力连续        0.120   \n",
       "1            IF99                IF           0.0      IF指数连续        0.120   \n",
       "2            TF88                TF           0.0    年期国债主力连续        0.012   \n",
       "3            TF99                TF           0.0    年期国债指数连续        0.012   \n",
       "4             T88                 T           0.0    年期国债主力连续        0.020   \n",
       "..            ...               ...           ...         ...          ...   \n",
       "962        IH2202                IH           0.0  上证50指数2202        0.120   \n",
       "963        IF2202                IF           0.0      IF2202        0.120   \n",
       "964        FU2301                FU           0.0     燃料油2301        0.100   \n",
       "965        SC2301                SC           0.0      原油2301        0.100   \n",
       "966        LU2301                LU           0.0   低硫燃料油2301        0.100   \n",
       "\n",
       "    maturity_date    type trading_code exchange     product  \\\n",
       "0      0000-00-00  Future       IF2203    CFFEX       Index   \n",
       "1      0000-00-00  Future       IF2203    CFFEX       Index   \n",
       "2      0000-00-00  Future       TF2203    CFFEX  Government   \n",
       "3      0000-00-00  Future       TF2203    CFFEX  Government   \n",
       "4      0000-00-00  Future        T2203    CFFEX  Government   \n",
       "..            ...     ...          ...      ...         ...   \n",
       "962    2022-02-18  Future       IH2202    CFFEX       Index   \n",
       "963    2022-02-18  Future       IF2202    CFFEX       Index   \n",
       "964    2022-12-30  Future       fu2301     SHFE   Commodity   \n",
       "965    2022-12-30  Future       sc2301      INE   Commodity   \n",
       "966    2022-12-30  Future       lu2301      INE   Commodity   \n",
       "\n",
       "     contract_multiplier  round_lot  \\\n",
       "0                  300.0        1.0   \n",
       "1                  300.0        1.0   \n",
       "2                10000.0        1.0   \n",
       "3                10000.0        1.0   \n",
       "4                10000.0        1.0   \n",
       "..                   ...        ...   \n",
       "962                300.0        1.0   \n",
       "963                300.0        1.0   \n",
       "964                 10.0        1.0   \n",
       "965               1000.0        1.0   \n",
       "966                 10.0        1.0   \n",
       "\n",
       "                                       trading_hours listed_date  \\\n",
       "0                            09:31-11:30,13:01-15:00  0000-00-00   \n",
       "1                            09:31-11:30,13:01-15:00  0000-00-00   \n",
       "2                            09:31-11:30,13:01-15:15  0000-00-00   \n",
       "3                            09:31-11:30,13:01-15:15  0000-00-00   \n",
       "4                            09:31-11:30,13:01-15:15  0000-00-00   \n",
       "..                                               ...         ...   \n",
       "962                          09:31-11:30,13:01-15:00  2021-12-20   \n",
       "963                          09:31-11:30,13:01-15:00  2021-12-20   \n",
       "964  21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "965  21:01-02:30,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "966  21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "\n",
       "    industry_name de_listed_date underlying_order_book_id  \n",
       "0              股指     0000-00-00              000300.XSHG  \n",
       "1              股指     0000-00-00              000300.XSHG  \n",
       "2              国债     0000-00-00                     None  \n",
       "3              国债     0000-00-00                     None  \n",
       "4              国债     0000-00-00                     None  \n",
       "..            ...            ...                      ...  \n",
       "962            股指     2022-02-18              000016.XSHG  \n",
       "963            股指     2022-02-18              000300.XSHG  \n",
       "964            能源     2022-12-30                     None  \n",
       "965            能源     2022-12-30                     None  \n",
       "966            能源     2022-12-30                     None  \n",
       "\n",
       "[967 rows x 17 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_future = all_instruments(type='Future', date='20211224')\n",
    "df_future"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_book_id</th>\n",
       "      <th>underlying_symbol</th>\n",
       "      <th>market_tplus</th>\n",
       "      <th>symbol</th>\n",
       "      <th>margin_rate</th>\n",
       "      <th>maturity_date</th>\n",
       "      <th>type</th>\n",
       "      <th>trading_code</th>\n",
       "      <th>exchange</th>\n",
       "      <th>product</th>\n",
       "      <th>contract_multiplier</th>\n",
       "      <th>round_lot</th>\n",
       "      <th>trading_hours</th>\n",
       "      <th>listed_date</th>\n",
       "      <th>industry_name</th>\n",
       "      <th>de_listed_date</th>\n",
       "      <th>underlying_order_book_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Y0805</td>\n",
       "      <td>Y</td>\n",
       "      <td>0.0</td>\n",
       "      <td>豆油0805</td>\n",
       "      <td>0.05</td>\n",
       "      <td>2008-05-16</td>\n",
       "      <td>Future</td>\n",
       "      <td>y0805</td>\n",
       "      <td>DCE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2007-05-22</td>\n",
       "      <td>油脂</td>\n",
       "      <td>2008-05-16</td>\n",
       "      <td>null</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Y0807</td>\n",
       "      <td>Y</td>\n",
       "      <td>0.0</td>\n",
       "      <td>豆油0807</td>\n",
       "      <td>0.05</td>\n",
       "      <td>2008-07-14</td>\n",
       "      <td>Future</td>\n",
       "      <td>y0807</td>\n",
       "      <td>DCE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2007-07-16</td>\n",
       "      <td>油脂</td>\n",
       "      <td>2008-07-14</td>\n",
       "      <td>null</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Y0808</td>\n",
       "      <td>Y</td>\n",
       "      <td>0.0</td>\n",
       "      <td>豆油0808</td>\n",
       "      <td>0.05</td>\n",
       "      <td>2008-08-14</td>\n",
       "      <td>Future</td>\n",
       "      <td>y0808</td>\n",
       "      <td>DCE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2007-08-15</td>\n",
       "      <td>油脂</td>\n",
       "      <td>2008-08-14</td>\n",
       "      <td>null</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Y0809</td>\n",
       "      <td>Y</td>\n",
       "      <td>0.0</td>\n",
       "      <td>豆油0809</td>\n",
       "      <td>0.05</td>\n",
       "      <td>2008-09-12</td>\n",
       "      <td>Future</td>\n",
       "      <td>y0809</td>\n",
       "      <td>DCE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2007-09-17</td>\n",
       "      <td>油脂</td>\n",
       "      <td>2008-09-12</td>\n",
       "      <td>null</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Y0811</td>\n",
       "      <td>Y</td>\n",
       "      <td>0.0</td>\n",
       "      <td>豆油0811</td>\n",
       "      <td>0.05</td>\n",
       "      <td>2008-11-14</td>\n",
       "      <td>Future</td>\n",
       "      <td>y0811</td>\n",
       "      <td>DCE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2007-11-15</td>\n",
       "      <td>油脂</td>\n",
       "      <td>2008-11-14</td>\n",
       "      <td>null</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7258</th>\n",
       "      <td>IH2202</td>\n",
       "      <td>IH</td>\n",
       "      <td>0.0</td>\n",
       "      <td>上证50指数2202</td>\n",
       "      <td>0.12</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>Future</td>\n",
       "      <td>IH2202</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>2021-12-20</td>\n",
       "      <td>股指</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>000016.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7259</th>\n",
       "      <td>IF2202</td>\n",
       "      <td>IF</td>\n",
       "      <td>0.0</td>\n",
       "      <td>IF2202</td>\n",
       "      <td>0.12</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>Future</td>\n",
       "      <td>IF2202</td>\n",
       "      <td>CFFEX</td>\n",
       "      <td>Index</td>\n",
       "      <td>300.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>09:31-11:30,13:01-15:00</td>\n",
       "      <td>2021-12-20</td>\n",
       "      <td>股指</td>\n",
       "      <td>2022-02-18</td>\n",
       "      <td>000300.XSHG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7260</th>\n",
       "      <td>FU2301</td>\n",
       "      <td>FU</td>\n",
       "      <td>0.0</td>\n",
       "      <td>燃料油2301</td>\n",
       "      <td>0.10</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>fu2301</td>\n",
       "      <td>SHFE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7261</th>\n",
       "      <td>SC2301</td>\n",
       "      <td>SC</td>\n",
       "      <td>0.0</td>\n",
       "      <td>原油2301</td>\n",
       "      <td>0.10</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>sc2301</td>\n",
       "      <td>INE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>1000.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-02:30,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7262</th>\n",
       "      <td>LU2301</td>\n",
       "      <td>LU</td>\n",
       "      <td>0.0</td>\n",
       "      <td>低硫燃料油2301</td>\n",
       "      <td>0.10</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>Future</td>\n",
       "      <td>lu2301</td>\n",
       "      <td>INE</td>\n",
       "      <td>Commodity</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00</td>\n",
       "      <td>2021-12-24</td>\n",
       "      <td>能源</td>\n",
       "      <td>2022-12-30</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7263 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     order_book_id underlying_symbol  market_tplus      symbol  margin_rate  \\\n",
       "0            Y0805                 Y           0.0      豆油0805         0.05   \n",
       "1            Y0807                 Y           0.0      豆油0807         0.05   \n",
       "2            Y0808                 Y           0.0      豆油0808         0.05   \n",
       "3            Y0809                 Y           0.0      豆油0809         0.05   \n",
       "4            Y0811                 Y           0.0      豆油0811         0.05   \n",
       "...            ...               ...           ...         ...          ...   \n",
       "7258        IH2202                IH           0.0  上证50指数2202         0.12   \n",
       "7259        IF2202                IF           0.0      IF2202         0.12   \n",
       "7260        FU2301                FU           0.0     燃料油2301         0.10   \n",
       "7261        SC2301                SC           0.0      原油2301         0.10   \n",
       "7262        LU2301                LU           0.0   低硫燃料油2301         0.10   \n",
       "\n",
       "     maturity_date    type trading_code exchange    product  \\\n",
       "0       2008-05-16  Future        y0805      DCE  Commodity   \n",
       "1       2008-07-14  Future        y0807      DCE  Commodity   \n",
       "2       2008-08-14  Future        y0808      DCE  Commodity   \n",
       "3       2008-09-12  Future        y0809      DCE  Commodity   \n",
       "4       2008-11-14  Future        y0811      DCE  Commodity   \n",
       "...            ...     ...          ...      ...        ...   \n",
       "7258    2022-02-18  Future       IH2202    CFFEX      Index   \n",
       "7259    2022-02-18  Future       IF2202    CFFEX      Index   \n",
       "7260    2022-12-30  Future       fu2301     SHFE  Commodity   \n",
       "7261    2022-12-30  Future       sc2301      INE  Commodity   \n",
       "7262    2022-12-30  Future       lu2301      INE  Commodity   \n",
       "\n",
       "      contract_multiplier  round_lot  \\\n",
       "0                    10.0        1.0   \n",
       "1                    10.0        1.0   \n",
       "2                    10.0        1.0   \n",
       "3                    10.0        1.0   \n",
       "4                    10.0        1.0   \n",
       "...                   ...        ...   \n",
       "7258                300.0        1.0   \n",
       "7259                300.0        1.0   \n",
       "7260                 10.0        1.0   \n",
       "7261               1000.0        1.0   \n",
       "7262                 10.0        1.0   \n",
       "\n",
       "                                        trading_hours listed_date  \\\n",
       "0     21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2007-05-22   \n",
       "1     21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2007-07-16   \n",
       "2     21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2007-08-15   \n",
       "3     21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2007-09-17   \n",
       "4     21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2007-11-15   \n",
       "...                                               ...         ...   \n",
       "7258                          09:31-11:30,13:01-15:00  2021-12-20   \n",
       "7259                          09:31-11:30,13:01-15:00  2021-12-20   \n",
       "7260  21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "7261  21:01-02:30,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "7262  21:01-23:00,09:01-10:15,10:31-11:30,13:31-15:00  2021-12-24   \n",
       "\n",
       "     industry_name de_listed_date underlying_order_book_id  \n",
       "0               油脂     2008-05-16                     null  \n",
       "1               油脂     2008-07-14                     null  \n",
       "2               油脂     2008-08-14                     null  \n",
       "3               油脂     2008-09-12                     null  \n",
       "4               油脂     2008-11-14                     null  \n",
       "...            ...            ...                      ...  \n",
       "7258            股指     2022-02-18              000016.XSHG  \n",
       "7259            股指     2022-02-18              000300.XSHG  \n",
       "7260            能源     2022-12-30                     None  \n",
       "7261            能源     2022-12-30                     None  \n",
       "7262            能源     2022-12-30                     None  \n",
       "\n",
       "[7263 rows x 17 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_future"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_future.to_csv(\"D:\\Data\\\\futures_202112.csv\", encoding='utf_8_sig')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "dingurl_xiaoce = \"https://oapi.dingtalk.com/robot/send?access_token=82bc909d7890a6a62dc2a250df8eea25d6666b1360a79de0d61b08483774fb36\"\n",
    "# dingurl_xiaoce = \"https://oapi.dingtalk.com/robot/send?access_token=a9e173459658eef1997dafa248d806d7e25b32b3ca7603058f9084104b8e454b\" \n",
    "# sanrenqun\n",
    "headers = {\"Content-Type\": \"application/json\"}\n",
    "jsonStr = {\"msgtype\": \"text\", \"text\": {\"content\": '[pro]'}}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "           \n",
    "requests.post(dingurl_xiaoce, json=jsonStr, headers=headers)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
